package com.star.jersey.mybatisplus.base.core.contract.exception;


import com.star.jersey.mybatisplus.base.core.contract.enums.ErrorCodeEnum;

import java.util.Map;
import java.util.StringJoiner;

public class ValidateException extends ServiceException {
    private static final long serialVersionUID = 412491531709952986L;
    private Map<String, String> errorMap;

    public ValidateException(Map<String, String> errorMap) {
        super(ErrorCodeEnum.PARAMETER_VALIDATION_FAILED.getCode(), ErrorCodeEnum.PARAMETER_VALIDATION_FAILED.getDesc());
        this.errorMap = errorMap;
    }

    public ValidateException(String errorMsg) {
        super(ErrorCodeEnum.PARAMETER_VALIDATION_FAILED.getCode(), errorMsg);
    }

    public String toString() {
        return (new StringJoiner(", ", ValidateException.class.getSimpleName() + "[", "]")).add("code=" + this.getErrCode()).add("msg=" + this.getMessage()).add("errorMap=" + this.errorMap).toString();
    }

    public Map<String, String> getErrorMap() {
        return this.errorMap;
    }
}
